package com.syni.mdd.yhd.common.all.config.pay.wxPay;

import com.syni.mdd.sjb.common.component.utils.common.spring.ApplicationContextHolder;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Profile;

/**
 * @className PublicAppWxPayBean
 * @description TOO
 * @Author cfx
 * @DATE 2019/11/29 19:16
 * @VERSION 1.0
 **/
@Data
@Configuration
@DependsOn("wxPayBeanFactory")
public class AppWxPayBean extends WxPayBean{
    private String appId = "wx4e16ef3485010cc0";
    private String appSecret = "";
    private String mchId = "1563829591";
    private String partnerKey = "z1SrP68ht18FExkDnuOLy7BsGaUdvyOh";
    private String certPath = "/home/syniapp/mdd_cloud/global_config/apiclient_cert.p12";
    private String domain = WxPayBeanFactory.DEV_BACK_URL + "/MDD_API/DSP_API";
    private String payNotifyUrl;
    private String refundNotifyUrl;
    private String appPayServiceCallBackUrl;

    @Bean(name = "APP")
    public AppWxPayBean getAppWxPayBean(){
        AppWxPayBean appWxPayBean = new AppWxPayBean();
        appWxPayBean.setAppId(appId);
        appWxPayBean.setMchId(mchId);
        appWxPayBean.setPartnerKey(partnerKey);
        appWxPayBean.setCertPath(certPath);
        appWxPayBean.setDomain(domain);
        appWxPayBean.setPayNotifyUrl(appWxPayBean.getDomain() + "/wxPay/payNotify");
        appWxPayBean.setRefundNotifyUrl(appWxPayBean.getDomain() + "/wxPay/refundNotify");
        appWxPayBean.setAppPayServiceCallBackUrl(appWxPayBean.getDomain() + "/wxPay/appPayServicePayNotify");
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            appWxPayBean.setDomain("https://w.syni.com/MDD_API/DSP_API");
            appWxPayBean.setPayNotifyUrl(appWxPayBean.getDomain() + "/wxPay/payNotify");
            appWxPayBean.setRefundNotifyUrl(appWxPayBean.getDomain() + "/wxPay/refundNotify");
            appWxPayBean.setAppPayServiceCallBackUrl(appWxPayBean.getDomain() + "/wxPay/appPayServicePayNotify");
        }
        return appWxPayBean;
    }
}
